home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 October: Technology Seed / ADC Seed CD - October 1999.toast / Carbon SDK 1.0d10c3 / Sample Code / AppearanceSample / ProgressPane.cp < prev    next >
Encoding:
Text File  |  1999-05-01  |  1.5 KB  |  86 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        ProgressPane.cp
  3.  
  4.     Contains:    Demonstration of different progress indicators.
  5.  
  6.     Version:    Appearance 1.0 SDK
  7.  
  8.     Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Edward Voas
  13.  
  14.         Other Contact:        7 of 9, Borg Collective
  15.  
  16.         Technology:            OS Technologies Group
  17.  
  18.     Writers:
  19.  
  20.         (edv)    Ed Voas
  21.  
  22.     Change History (most recent first):
  23.  
  24.          <2>     9/25/97    edv        Get rid of movie stuff for now.
  25.          <1>     9/11/97    edv        First checked in.
  26. */
  27.  
  28. #include "AppearanceSamplePrefix.h"
  29.  
  30. #include <Appearance.h>
  31. #include <Resources.h>
  32. #include "ProgressPane.h"
  33. #include "AppearanceHelpers.h"
  34.  
  35. enum
  36. {
  37.     kProgress1 = 1,
  38.     kProgress2 = 2
  39. };
  40.  
  41. ProgressPane::ProgressPane( DialogPtr dialog, SInt16 items ) : MegaPane( dialog, items )
  42. {
  43.     AppendDialogItemList( dialog, 6001, overlayDITL );
  44.     
  45.     fProgressValue = 0;
  46.     fIsAscending = true;
  47.     
  48.     GetDialogItemAsControl( dialog, items + kProgress1, &fProgress1 );
  49.     GetDialogItemAsControl( dialog, items + kProgress2, &fProgress2 );
  50.     
  51.     SetProgressIndicatorState( fProgress2, false );
  52.  
  53.     RequestIdleTime( 50 );
  54. }
  55.  
  56. ProgressPane::~ProgressPane()
  57. {
  58.     ShortenDITL( fDialog, CountDITL( fDialog ) - fOrigItems );
  59. }
  60.  
  61. void
  62. ProgressPane::Idle()
  63. {
  64.     IdleControls( GetDialogWindow( fDialog ) );
  65.     
  66.     if ( fIsAscending )
  67.     {
  68.         fProgressValue += 2;
  69.         if ( fProgressValue > 100 )
  70.         {
  71.             fProgressValue = 98;
  72.             fIsAscending = false;
  73.         }
  74.     }
  75.     else
  76.     {
  77.         fProgressValue -= 2;
  78.         if ( fProgressValue < 0 )
  79.         {
  80.             fProgressValue = 2;
  81.             fIsAscending = true;
  82.         }
  83.     }
  84.     SetControlValue( fProgress1, fProgressValue );
  85. }
  86.